import { getUserNiubi } from 'config/api';
export default {
  namespace: 'wallet',
  state: {
    niu_bi: 0,
    headerMenuFirst: [
      {
        name: '待返本金',
        data: 0
      },
      {
        name: '待返现金分红',
        data: 0
      },
      {
        name: '待返橙点分红',
        data: 0
      }
    ],
    headerMenuSecond: [
      {
        name: '累计现金分红',
        data: 0.0
      },
      {
        name: '累计橙点分红',
        data: 0
      }
    ],
    headerMenuThird: [
      {
        text: '回款日历',
        iconSrc: require('src/assets/回款日历.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '购买记录',
        iconSrc: require('src/assets/购买记录.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '提现',
        iconSrc: require('src/assets/提现.png'),
        url: '/layout/record?tabName=muniuren'
      }
    ],
    listData: [
      {
        text: '全部牛币流水',
        iconSrc: require('src/assets/账单流水.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '充值记录',
        iconSrc: require('src/assets/充值记录.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '提现记录',
        iconSrc: require('src/assets/提现记录.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '分红记录',
        iconSrc: require('src/assets/分红记录.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '历史购买支出',
        iconSrc: require('src/assets/历史购买支出.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '已到期返回款',
        iconSrc: require('src/assets/已到期返回款.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '橙点流水',
        iconSrc: require('src/assets/橙点流水.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '推广佣金收入',
        iconSrc: require('src/assets/推广佣金收入.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '其他消费记录',
        iconSrc: require('src/assets/其他消费记录.png'),
        url: '/layout/record?tabName=muniuren'
      },
      {
        text: '参与活动支出',
        iconSrc: require('src/assets/参与活动支出.png'),
        url: '/layout/record?tabName=muniuren'
      }
    ]
  },
  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    }
  },
  effects: {
    *getUserNiubiEff(action, { call, put, select }) {
      let { niu_bi } = yield call(getUserNiubi);
      yield put({ type: 'save', payload: { niu_bi } });
      let headerData = yield select(state => state.muniuren.headerData);
			console.log("​*getUserNiubiEff -> headerData", headerData)
      headerData[1].data = niu_bi;
      yield put({ type: 'muniuren/save', payload: { headerData } });
    }
  }
};
